 <html>
<head>



<script type="text/javascript" src="build/yahoo/yahoo-min.js"></script>
<script type="text/javascript" src="build/event/event-min.js"></script>
<script type="text/javascript" src="build/connection/connection-min.js"></script>
<script type="text/javascript" src="build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="build/menu/menu-min.js"></script>
<script type="text/javascript" src="build/element/element-beta-min.js"></script>
<script type="text/javascript" src="build/datasource/datasource-beta-min.js"></script>
<script type="text/javascript" src="build/datatable/datatable-beta-min.js"></script>
<script type="text/javascript" src="build/dragdrop/dragdrop-min.js"></script> 
<script type="text/javascript" src="build/container/container-min.js"></script>
<script type="text/javascript" src="build/animation/animation-min.js"></script>
<script type="text/javascript" src="build/button/button-min.js"></script>

<script type="text/javascript" src="init.js"></script>
<script type="text/javascript" src="karyotypeRequests.js"></script>
<script type="text/javascript" src="dasParsers.js"></script>
<script type="text/javascript" src="classes.js"></script>
<script type="text/javascript" src="util.js"></script>
<script type="text/javascript" src="karyotypeStructureFunctions.js"></script>
<script type="text/javascript" src="drawKaryotypeStructure.js"></script>
<script type="text/javascript" src="drawAnnotations.js"></script>





<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/menu/assets/skins/sam/menu.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/button/assets/skins/sam/button.css" />
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>

<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/container/container_core-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/menu/menu-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/element/element-beta-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/button/button-min.js"></script>


<script>

//var rafa = new Array();

function makeSpecieRequest(){
	var url = YAHOO.dasBrowser.genome.karyotypeStructure.proxyUrl + "?" + YAHOO.dasBrowser.proxy.parameters.source + "=" + YAHOO.dasBrowser.genome.karyotypeStructure.referenceUrl + "dsn";
    var request = YAHOO.util.Connect.asyncRequest('GET', url, specieRequestCallback);
	//console.log(request);
}


var specieRequestCallback = {
    success:function(o){
		var dasUrl = YAHOO.dasBrowser.genome.karyotypeStructure.referenceUrl;
		var ensemblDsnResults = YAHOO.dasBrowser.genome.karyotypeStructure.dsn.parseEnsemblDsn(o.responseXML, YAHOO.dasBrowser.genome.karyotypeStructure.dsn.selectedDsn.id);
		//YAHOO.dasBrowser.util.displayObjProp(ensemblDsnResults.allEnsemblDsn);
		//console.log(o.responseXML);
		var specieMenu = new Array();
		for(var i = 0; i < ensemblDsnResults.allEnsemblDsn.length; i++){
			if(ensemblDsnResults.allEnsemblDsn[i].sourceType == 'karyotype'){
				var splitReferenceUrl = ensemblDsnResults.allEnsemblDsn[i].referenceUrl.split(dasUrl);
				var sourceSpecie = ensemblDsnResults.allEnsemblDsn[i].sourceSpecie;
				var sourceRelease = ensemblDsnResults.allEnsemblDsn[i].sourceRelease;
				var menuText = sourceSpecie + ' ' + sourceRelease;
				var menuValue = splitReferenceUrl[1];
				
				var specieRow = new Object();
				specieRow.text = menuText;
				specieRow.value = menuValue;
				specieRow.onclick = { fn: onMenuItemClick };
				specieMenu.push(specieRow);
				//console.log(menuText);
				//console.log(menuValue);
			}
		}

		var oMenuButton4 = new YAHOO.widget.Button({ type: "menu", label: "species", name: "mymenubutton", menu: specieMenu, container: "menubuttonsfromjavascript" });            

		

    },
    failure:function(o){
		console.log("failure");
	}
}

        function onMenuItemClick(p_sType, p_aArgs, p_oItem) {

            alert(p_oItem.cfg.getProperty("text"));
                            
        }


        function onExampleSubmit(p_oEvent) {

            var bSubmit = window.confirm("Are you sure you want to submit this form?");

            if(!bSubmit) {
            
                YAHOO.util.Event.preventDefault(p_oEvent);
            
            }

        }

        YAHOO.util.Event.on("button-example-form", "submit", onExampleSubmit);
		


YAHOO.util.Event.addListener(window, 'load', makeSpecieRequest);

</script>
    </head>
    <body class="yui-skin-sam">
<div id="title" align="left" style="margin: 0px;"><img src="img/bioinfo.png"></div>

<div id="species"></div>
<form id="button-example-form" name="button-example-form" method="post" action="#">
<fieldset id="menubuttonsfromjavascript">
            <legend>From JavaScript</legend>
        </fieldset>
</form>

      
    </body>
</html>
